//注意 我为了设置默认值，把max_days参数放在了最后面，跟原题有区别
function filter_checkin_logs(checkin_days, shown_days = 8,max_days=30,) {
    let begin = 0
    let end = 0
    if (checkin_days <= 0) {
        begin = 1;
        end = shown_days;
    }
    else if (checkin_days > 0 && checkin_days < max_days - shown_days + 1) {
        begin = checkin_days;
        end = checkin_days + shown_days - 1;
    }
    else{
        begin = max_days - shown_days + 1;
        end = max_days
    }
    return {
        begin,
        end,
    }
}
console.log(filter_checkin_logs(0));
console.log(filter_checkin_logs(7));
console.log(filter_checkin_logs(28));

//其中max_days 可以用下面这个方法，获取当前月的天数；
function mGetDate(){
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth()+1;
    var d = new Date(year, month, 0);
    return d.getDate();
}